package com.ruoyi.wechat.api;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.wechat.domain.Camp;
import com.ruoyi.wechat.service.ICampService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 微信小程序API：营地管理Controller
 *
 */
@RestController
@RequestMapping("/wechat/camp")
public class WxCampController extends BaseController
{
    @Autowired
    private ICampService campService;
    /**
     * 查询营地管理列表
     */
    @ApiOperation("营地列表")
    @GetMapping("/wxlist")
    public TableDataInfo list(Camp camp)
    {
        startPage();
        List<Camp> list = campService.selectCampList(camp);
        return getDataTable(list);
    }


    /**
     * 获取营地管理详细信息
     */
    @GetMapping(value = "/get/{campId}")
    public AjaxResult getInfo(@PathVariable("campId") String campId)
    {
        return success(campService.selectCampByCampId(campId));
    }

    @Autowired
    private TokenService tokenService;
    /**
     * 新增营地管理
     */
    @PostMapping("wxadd")
    public AjaxResult add(@RequestBody Camp camp, HttpServletRequest request)
    {
        //获取用户id


        return success(campService.insertCamp(camp));
    }

    /**
     * 修改营地管理
     */
    @PutMapping("update")
    public AjaxResult edit(@RequestBody Camp camp)
    {
        return toAjax(campService.updateCamp(camp));
    }

    /**
     * 删除营地管理
     */
	@DeleteMapping("/delete/{campIds}")
    public AjaxResult remove(@PathVariable String[] campIds)
    {
        return toAjax(campService.deleteCampByCampIds(campIds));
    }
}











